<?php
class SqlJoin extends Object
{
	public $table;
	public $field;
	public $refField;
	public $leftjoin;

    public function SqlJoin($table, $field, $reffield, $leftjoin = false)
	{
		$this->table = $table;
		$this->field = $field;
		$this->refField = $reffield;
		$this->leftjoin = $leftjoin;
	}

    public static function GetFromFK($fks)
	{
		$relations = array();
		if (is_array($fks))
		{
	        foreach ($fks as $field_name => $fk)
			{
				$relations[] = new SqlJoin($fk->table, $field_name, $fk->field, $fk->leftJoin);
			}
		}
		return $relations;
	}
}
?>
